package com.wanmait.happyheating.service.impl;

import com.wanmait.happyheating.pojo.Address;
import com.wanmait.happyheating.pojo.Workers;
import com.wanmait.happyheating.mapper.WorkersMapper;
import com.wanmait.happyheating.service.WorkersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 * 维修人员表 服务实现类
 * </p>
 *
 * @author yuQianTao
 * @since 2021-05-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WorkersServiceImpl extends ServiceImpl<WorkersMapper, Workers> implements WorkersService {
    @Resource WorkersMapper workersMapper;

    /**
     * 用户下单时查询所有可以用的时间段
     * 通过判断该时间段下有没有空闲维修人员来实现
     * @param freeTime 目标查询的时间点
     * @param addressId 地址的ID
     * @param address   heatingNUM中的地址
     * @return  该时间点下的所有的维修人员
     */
    @Override
    public List<Workers> findWorkerByFreeTime(String freeTime, Integer addressId, String address) {
        System.out.println("freetime"+freeTime);
        return workersMapper.findWorkerByFreeTime(freeTime.trim(),addressId,address);
    }

    /**
     * 根据订单中的下单时间查找辖区下的所有的维修人员
     * @param timestamp 订单开始时间
     * @return 可以用的维修人员的集合
     */
    @Override
    public List<Workers> findWorker(Timestamp timestamp) {
        return workersMapper.findWorker(timestamp);
    }
}
